package com.wt.springsamples.security.dto;

import com.wt.springsamples.model.SysUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

public class LoginUser implements UserDetails {

    private SysUser sysUser;
    private Collection<? extends GrantedAuthority> authorities;

    public LoginUser(SysUser sysUser, Collection<? extends GrantedAuthority> authorities){
        this.sysUser = sysUser;
        this.authorities=authorities;
    }

    public SysUser getUser() {
        return sysUser;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return sysUser.getLoginPwd();
    }

    @Override
    public String getUsername() {
        return sysUser.getLoginName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
